<%@ Page Language="C#" MasterPageFile="~/manager/logger.master" AutoEventWireup="true"
    CodeFile="parkings.aspx.cs" Inherits="SmartParking.Web.Manager.Parkings" Title="SmartParking >> Manager :: Parkings" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Assembly="ADEVSO" Namespace="ADEVSO.Web.UI.WebControls" TagPrefix="ADEVSO" %>
<asp:Content ID="Content1" ContentPlaceHolderID="LoggerContentPlaceHolder" runat="Server">
    <script type="text/javascript">
        $(document).ready(function () {
            //setup new park dialog
            $('#pnlParkForm').dialog({
                autoOpen: false,
                closeOnEscape: true,
                draggable: false,
                modal: true,
                resizable: false,
                closeText: ' ',
                open: function (type, data) {
                    $(this).parent().appendTo("form");
                }
            });

            //setup new park dialog
            $('#pnlZoneForm').dialog({
                autoOpen: false,
                closeOnEscape: true,
                draggable: false,
                modal: true,
                resizable: false,
                closeText: ' ',
                open: function (type, data) {
                    $(this).parent().appendTo("form");
                }
            });

        });

        function showDialog(id) {
            $('#' + id).dialog("open");
        }

        function closeDialog(id) {
            $('#' + id).dialog("close");
        }
              
    </script>
    <asp:UpdatePanel ID="upParking" UpdateMode="Conditional" runat="server">
        <ContentTemplate>
            <asp:Label ID="lbCustomer" runat="server" Text="Customer:" AssociatedControlID="cboxCustomer" />
            <asp:DropDownList ID="cboxCustomer" runat="server">
            </asp:DropDownList>
            <br />
            <br />
            <table width="100%" border="0" cellspacing="8" cellpadding="2">
                <tr>
                    <td>
                        <h1>
                            Manage Parkings</h1>
                    </td>
                </tr>
                <tr>
                    <td>
                        <ADEVSO:GridView ID="grdParkings" runat="server" AutoGenerateColumns="False" EnableViewState="true"
                            EmptyDataText="No parkings found." EmptyTableRowText="TEST" CellPadding="3" OnRowCommand="grdParkings_RowCommand">
                            <Columns>
                                <asp:TemplateField HeaderText="IdPark" Visible="false">
                                    <ItemTemplate>
                                        <asp:Label ID="lbIdPark" runat="server" Text='<%# Bind("ParkingID") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Parking">
                                    <ItemTemplate>
                                        <asp:Label ID="lbName" runat="server" Text='<%# Bind("Name") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Bank Account Number">
                                    <ItemTemplate>
                                        <asp:Label ID="lbBankAccountNumber" runat="server" Text='<%# Bind("BankAccountNumber") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lbtnEdit" runat="server" Text="Edit" CausesValidation="false"
                                            CommandName="EditPark" CommandArgument='<%# Bind("ParkingID") %>'></asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lbtnDelete" runat="server" Text="Delete" CommandName="DeletePark"
                                            CausesValidation="false" CommandArgument='<%# Bind("ParkingID") %>'></asp:LinkButton>
                                        <cc1:ConfirmButtonExtender ID="ceDelete" runat="server" ConfirmText="Are you sure that want to delete this park?"
                                            TargetControlID="lbtnDelete">
                                        </cc1:ConfirmButtonExtender>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lbtnZones" runat="server" Text="Zones" CommandName="Zones" CausesValidation="false"
                                            CommandArgument='<%# Bind("ParkingID") %>'></asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </ADEVSO:GridView>
                        <br />
                        <asp:LinkButton ID="lnkAddParking" runat="server" CausesValidation="false" OnClientClick="showDialog('pnlParkForm');">Add Parking</asp:LinkButton>
                    </td>
                </tr>
                <tr>
                    <td id="zoneheader" runat="server" visible="false">
                        <h1>
                            Manage Zones</h1>
                    </td>
                </tr>
                <tr>
                    <td id="zonegrid" runat="server" visible="false">
                        <ADEVSO:GridView ID="grdParkingZones" runat="server" CaptionAlign="Top" AutoGenerateColumns="False"
                            GridLines="Horizontal" ShowResultSummary="true" AscendingImageUrl="~/media/img/SortAsc.gif"
                            EmptyDataText="No zones found." DescendingImageUrl="~/media/img/SortDesc.gif"
                            ForeColor="#333333" PageSize="5" CellPadding="3" OnRowCommand="grdParkingZones_RowCommand">
                            <PagerSettings Mode="NumericFirstLast" Position="Bottom" />
                            <Columns>
                                <asp:TemplateField HeaderText="IdPark" SortExpression="IdPark" Visible="false">
                                    <ItemTemplate>
                                        <asp:Label ID="lbIdPark" runat="server" Text='<%# Bind("ParkingID") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="IdParkZone" SortExpression="IdParkZone" Visible="false">
                                    <ItemTemplate>
                                        <asp:Label ID="lbIdParkZone" runat="server" Text='<%# Bind("ParkingZoneID") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Zone" SortExpression="Name">
                                    <ItemTemplate>
                                        <asp:Label ID="lbName" runat="server" Text='<%# Bind("Name") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Manager Commision Amount" SortExpression="ManagerCommisionAmount">
                                    <ItemTemplate>
                                        <asp:Label ID="lbManagerCommisionAmount" runat="server" Text='<%# Bind("ManagerCommisionAmount") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Web Commision Amount" SortExpression="WebCommisionAmount">
                                    <ItemTemplate>
                                        <asp:Label ID="lbWebCommisionAmount" runat="server" Text='<%# Bind("WebCommisionAmount") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Allow Half Hour" SortExpression="AllowHalfHour" ItemStyle-HorizontalAlign="Center">
                                    <ItemTemplate>
                                        <asp:Label ID="lbAllowHalfHour" runat="server" Text='<%# DisplayBoolean(Eval("AllowHalfHour")) %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Open" SortExpression="OpenHour" ItemStyle-HorizontalAlign="Center">
                                    <ItemTemplate>
                                        <asp:Label ID="lbOpenHour" runat="server" Text='<%# DisplayHour(Eval("OpenHour")) %>' />
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Center" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Close" SortExpression="CloseHour" ItemStyle-HorizontalAlign="Center">
                                    <ItemTemplate>
                                        <asp:Label ID="lbCloseHour" runat="server" Text='<%# DisplayHour(Eval("CloseHour")) %>' />
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Center" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Regular Spaces" SortExpression="RegularSpaces">
                                    <ItemTemplate>
                                        <asp:Label ID="lbRegularSpaces" runat="server" Text='<%# Bind("RegularSpaces") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Spaces To Reserve" SortExpression="SpacesToReserve">
                                    <ItemTemplate>
                                        <asp:Label ID="lbSpacesToReserve" runat="server" Text='<%# Bind("SpacesToReserve") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lbtnEdit" runat="server" Text="Edit" CommandName="EditZone" CausesValidation="false"
                                            CommandArgument='<%# Bind("ParkingZoneID") %>'></asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lbtnDelete" runat="server" Text="Delete" CausesValidation="false"
                                            CommandName="DeleteZone" CommandArgument='<%# Bind("ParkingZoneID") %>'></asp:LinkButton>
                                        <cc1:ConfirmButtonExtender ID="ceDelete" runat="server" ConfirmText="Are you sure that want to delete this park?"
                                            TargetControlID="lbtnDelete">
                                        </cc1:ConfirmButtonExtender>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <ADEVSO:CommandField ShowHeader="True" />
                            </Columns>
                        </ADEVSO:GridView>
                        <br />
                        <asp:LinkButton ID="lbtnAddZone" runat="server" CausesValidation="false" OnClientClick="showDialog('pnlZoneForm');">Add Zone</asp:LinkButton>
                    </td>
                </tr>
            </table>
            <br />
            <br />
        </ContentTemplate>
    </asp:UpdatePanel>
    <div id='pnlParkForm' class="modalPopup">
        <asp:UpdatePanel ID="upParkingForm" UpdateMode="Conditional" ChildrenAsTriggers="true"
            runat="server">
            <ContentTemplate>
                <h2>
                    <asp:Label ID="lblParkTitle" runat="server" Text="Add Parking"></asp:Label>
                    <asp:HiddenField ID="hfId" runat="server" />
                </h2>
                <table>
                    <tr>
                        <td>
                            Name:
                        </td>
                        <td>
                            <asp:TextBox ID="txtName" runat="server" ValidationGroup="Park"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvName" runat="server" ErrorMessage="*" ForeColor="Red"
                                ValidationGroup="Park" Font-Bold="true" ControlToValidate="txtName"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Bank Account Number:
                        </td>
                        <td>
                            <asp:TextBox ID="txtBankAccountNumber" runat="server" ValidationGroup="Park"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvBankAccountNumber" runat="server" ErrorMessage="*"
                                ValidationGroup="Park" ForeColor="Red" Font-Bold="true" ControlToValidate="txtBankAccountNumber"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:Button ID="btnSubmitPark" runat="server" OnClick="btnSubmitPark_Click" Text="Save"
                                ValidationGroup="Park" />
                            &nbsp;
                            <asp:Button ID="btnCancelPark" runat="server" Text="Cancel" CausesValidation="false"
                                OnClick="btnCancelPark_Click" />
                            &nbsp;
                            <asp:Button ID="btnDeletePark" runat="server" Text="Delete" CausesValidation="false"
                                Visible="false" OnClick="btnDeletePark_Click" />
                            <cc1:ConfirmButtonExtender ID="cbeDelete" runat="server" ConfirmText="Are you sure that want to delete this park?"
                                TargetControlID="btnDeletePark">
                            </cc1:ConfirmButtonExtender>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:UpdateProgress ID="uprPark" runat="server" AssociatedUpdatePanelID="upParkingForm">
            <ProgressTemplate>
                <tr>
                    <td colspan="2" align="center">
                        <asp:Image ID="imgProgressPark" runat="server" ImageUrl="~/media/img/progress.gif" />
                        <asp:Label ID="lblWaitPark" runat="server" Text="Please wait..." />
                    </td>
                </tr>
            </ProgressTemplate>
        </asp:UpdateProgress>
    </div>
    <div id='pnlZoneForm' class="modalPopup">
        <asp:UpdatePanel ID="upParkingZoneForm" UpdateMode="Conditional" ChildrenAsTriggers="true"
            runat="server">
            <ContentTemplate>
                <h2>
                    <asp:Label ID="lblZoneTitle" runat="server" Text="Add Zone"></asp:Label>
                    <asp:HiddenField ID="hfParkZoneid" runat="server" />
                    <asp:HiddenField ID="hfZoneid" runat="server" />
                </h2>
                <table>
                    <tr>
                        <td>
                            Name:
                        </td>
                        <td>
                            <asp:TextBox ID="txtZoneName" runat="server" ValidationGroup="Zone"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvZoneName" runat="server" ErrorMessage="*" ForeColor="Red"
                                ValidationGroup="Zone" Font-Bold="true" ControlToValidate="txtZoneName"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Price Hour:
                        </td>
                        <td>
                            <asp:TextBox ID="txtPriceHour" runat="server" ValidationGroup="Zone"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvPriceHour" runat="server" ErrorMessage="*" ForeColor="Red"
                                ValidationGroup="Zone" Font-Bold="true" ControlToValidate="txtPriceHour"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Manager Commision Amount:
                        </td>
                        <td>
                            <asp:TextBox ID="txtManagerCommision" runat="server" ValidationGroup="Zone"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvManagerCommision" runat="server" ErrorMessage="*"
                                ValidationGroup="Zone" ForeColor="Red" Font-Bold="true" ControlToValidate="txtManagerCommision"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Web Commision Amount:
                        </td>
                        <td>
                            <asp:TextBox ID="txtWebCommision" runat="server" ValidationGroup="Zone"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvWebCommision" runat="server" ErrorMessage="*"
                                ValidationGroup="Zone" ForeColor="Red" Font-Bold="true" ControlToValidate="txtWebCommision"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Reserve Amount:
                        </td>
                        <td>
                            <asp:TextBox ID="txtReserve" runat="server" ValidationGroup="Zone"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvReserve" runat="server" ErrorMessage="*" ValidationGroup="Zone"
                                ForeColor="Red" Font-Bold="true" ControlToValidate="txtReserve"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Allow Half Hour:
                        </td>
                        <td>
                            <asp:CheckBox ID="cbxAllowHalfHour" runat="server" ValidationGroup="Zone" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Open Hour:
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlOpenHour" runat="server" ValidationGroup="Zone">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Close Hour:
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlCloseHour" runat="server" ValidationGroup="Zone">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Regular Spaces:
                        </td>
                        <td>
                            <asp:TextBox ID="txtRegularSpaces" runat="server" ValidationGroup="Zone"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvRegularSpaces" runat="server" ErrorMessage="*"
                                ValidationGroup="Zone" ForeColor="Red" Font-Bold="true" ControlToValidate="txtRegularSpaces"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Spaces for Reserve:
                        </td>
                        <td>
                            <asp:TextBox ID="txtSpacesForReserve" runat="server" ValidationGroup="Zone"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvSpacesForReserve" runat="server" ErrorMessage="*"
                                ValidationGroup="Zone" ForeColor="Red" Font-Bold="true" ControlToValidate="txtSpacesForReserve"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:Button ID="btnSubmitZone" runat="server" Text="Save" ValidationGroup="Zone"
                                OnClick="btnSubmitZone_Click" />
                            &nbsp;
                            <asp:Button ID="btnCancelZone" runat="server" Text="Cancel" CausesValidation="false"
                                OnClick="btnCancelZone_Click" />
                            &nbsp;
                            <asp:Button ID="btnDeleteZone" runat="server" Text="Delete" CausesValidation="false"
                                Visible="false" OnClick="btnDeleteZone_Click" />
                            <cc1:ConfirmButtonExtender ID="cbtneZone" runat="server" ConfirmText="Are you sure that want to delete this park zone?"
                                TargetControlID="btnDeleteZone">
                            </cc1:ConfirmButtonExtender>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:UpdateProgress ID="uprZone" runat="server" AssociatedUpdatePanelID="upParkingZoneForm">
            <ProgressTemplate>
                <tr>
                    <td colspan="2" align="center">
                        <asp:Image ID="imgProgressZone" runat="server" ImageUrl="~/media/img/progress.gif" />
                        <asp:Label ID="lblWaitZone" runat="server" Text="Please wait..." />
                    </td>
                </tr>
            </ProgressTemplate>
        </asp:UpdateProgress>
    </div>
</asp:Content>
